package com.ssh.nio.buffer;

import java.io.IOException;
import java.nio.ByteBuffer;

public class BytebufferTest {

	public static void main(String[] args) throws IOException {
		ByteBuffer buffer = ByteBuffer.allocate(1111);

		while (true) {

			int c = System.in.read();

			if (c == -1)
				break;

			buffer.put((byte) c);

			if (c == '\n') {

				buffer.flip();
//				byte[] content = new byte[buffer.limit()];
//
//				buffer.get(content);

//				System.out.println(new String(content));
				System.out.println(new String(buffer.array()));
				buffer.clear();
			}

		}

	}
}
